const route = require("koa-route");
const Koa = require("koa");
const app = new Koa();

const data = require("./mock-data");

for (let key in data) {
  app.use(
    route.get(key, (ctx) => {
      let cookie = ctx.header.cookie;
      console.log("apiserver收取到了查询条件为：", ctx.querystring);
      console.log("apiserver收取到cookie为：", cookie);
      ctx.body = data[key];
    })
  );
}

app.listen(4000);
console.log("listening on port 4000");
